Python: Parse class bases like function arguments - #22301
Conversation
|
Good |
|
Hi. Thanks for your contribution; could you perhaps add some test cases as well? |
I can try. It's not really clear to me how the parser tests work. Do I see it correctly that in |
Yes, that looks like the right place to add the tests (example: #17822). |
|
@hvitved thanks for the pointers! Created, verified and added a test with expected output. This should cover just about all cases of expressions regularly used as class bases. |
hvitved
left a comment
There was a problem hiding this comment.
Code change looks plausible to me, but I would like someone from @github/codeql-python to confirm. Thanks again for the contribution.
tausbn
left a comment
There was a problem hiding this comment.
This looks good to me! Thank you for the contribution. ❤️
There are a few formalities that need to be taken care of (adding a change note and bumping the extractor version), but I can take care of that, and just tack the commits on to the end of the PR, and then we can merge it.
This PR adjusts how class bases are parsed to match the parsing of function arguments.
Previously, any node with a
valuefield was excluded to reject dict-splats as bases; this would also reject many other valid nodes, critically subscripts as used for typing (e.g.list[int]). Now, the undesired node types are explicitly rejected.Closes #22298.